#include "ConfigReader.h"
#include "IOError.h"

using namespace std;

int main(int argc,char *argv[])
{
  ConfigReader cr;

  cout << "test_ConfigReader:" << endl << endl;

  for(int i=0; i<argc; i++)
    cout << "argv[" << i << "] == " << argv[i] << endl;

  try {
      cr.getConfigFileName(&argc,argv);
  } catch(IOError ioe) {
    cout << ioe.getMsg() << endl; exit(1);
  }

  if(!cr.cfg_filename) {
      cr.cfg_filename = "test.cfg";
  }

  cout << "config filename: " << cr.cfg_filename << endl;

  for(int i=0; i<argc; i++)
    cout << "argv[" << i << "] == " << argv[i] << endl;

  try {
    cr.readConfigFile();
  } catch(IOError ioe) {
    cout << ioe.getMsg() << endl;
  }

  cout << "found " << cr.fargc << " options in file" << endl << endl;

  for(int i=0; i<cr.fargc; i++)
    cout << "fargv[" << i << "] == \"" << cr.fargv[i] << "\"" << endl;

  return 0;
}
